#include "heater.h"
#include "ui_heater.h"

Heater::Heater(QString Who, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Heater)
{
    ui->setupUi(this);
    WhoAmI = Who;
    WhereFins = new Fins;
    InitSettings = new QSettings("Init2.ini",QSettings::IniFormat);
    InitSettings->setIniCodec( "utf8" );
    QString PropName = WhoAmI + "/Name";
    QString Name = InitSettings->value((PropName)).toString();

    QPushButton *buttonSelectF = new QPushButton(tr(Name.toAscii()));
    PropName = WhoAmI + "/FirstLabel";
    Name = InitSettings->value((PropName)).toString();
    QLabel *labelTemp = new QLabel(Name);

    PropName = WhoAmI + "/SecondLabel";
    Name = InitSettings->value((PropName)).toString();
    QLabel *labelPower = new QLabel(Name);
    TStop = new OmronFloat(Who, "TStop", this);
    TTask = new OmronFloat(Who, "TTask", this);
    TErr = new OmronFloat(Who, "TErr", this);
    TProg = new OmronFloat(Who, "TProg", this);
    PMax = new OmronFloat(Who, "PMax", this);
    PCur = new OmronFloat(Who, "PCur", this);
    PMode = new OmronText(Who, "PMode", this);

    QVBoxLayout *VBox =  new QVBoxLayout;
    VBox->addWidget(buttonSelectF);
    VBox->addWidget(labelTemp);
    VBox->addWidget(TStop);
    VBox->addWidget(TTask);
    VBox->addWidget(TErr);
    VBox->addWidget(TProg);
    VBox->addWidget(labelPower);
    VBox->addWidget(PMax);
    VBox->addWidget(PCur);
    VBox->addWidget(PMode);
    setLayout(VBox);
}

Heater::~Heater()
{
    delete ui;
}

void Heater::SetWhereFins(Fins *addr)
{

    this->WhereFins = addr;
    TStop->SetWhereFins(WhereFins);
    TTask->SetWhereFins(WhereFins);
    TErr->SetWhereFins(WhereFins);
    TProg->SetWhereFins(WhereFins);
    PMax->SetWhereFins(WhereFins);
    PCur->SetWhereFins(WhereFins);
    PMode->SetWhereFins(WhereFins);
}

void Heater::nextField (const QString & WhoSend)
{
    qDebug()<<"Heater nextField"<<WhoSend;
}
void Heater::prevField (const QString & WhoSend)
{
    qDebug()<<"Heater prevField"<<WhoSend;
}



